package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.domain.entity.ProductComments;
import org.example.mapper.ProductCommentsMapper;
import org.example.service.ProductCommentsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ProductCommentsServiceImpl implements ProductCommentsService {
    @Resource
    private ProductCommentsMapper commentsMapper;
    @Override
    public List<ProductComments> queryComments(Integer productId) {
        QueryWrapper<ProductComments> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id",productId);
        return commentsMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean updateComment(ProductComments com) {
        return commentsMapper.updateById(com)>1;
    }

    @Override
    public Boolean deleteComment(Integer comId) {
        return commentsMapper.deleteById(comId)>0;
    }

    @Override
    public Boolean insertComment(ProductComments com) {
        return commentsMapper.insert(com)>0;
    }
}
